//
// Created by harrybao on 2019/4/4.
//

#pragma once

#define NEW_OBJECT(cls, ...)    ObjectPool<cls>::Instance()->New(__VA_ARGS__)

#define DELETE_OBJECT(obj) \
    if (nullptr != obj) \
    {\
        size_t hash_code = typeid(*obj).hash_code();\
        Game::Instance()->GetObjectPoolManager()->Recycle(hash_code, obj);\
        obj = nullptr;\
    }

#define NEW_ARRAY(class_name, num) \
        new class_name[num]
#define DELETE_ARRAY(array) \
        if(array != nullptr) delete [] array, array = nullptr

#define HOST_PTR(ptr, type, member) \
        ((type*)((char*)(ptr) - ((size_t)&((type*)0)->member)))
//((type *)((char *)(ptr) - offsetof(type, member)))
